<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QHistoryState Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QHistoryState Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QHistoryState class provides a means of returning to a
previously active substate. <a href="#details">More...</a></p>

<p>Inherits <a href="qabstractstate.html">QAbstractState</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qhistorystate.html#HistoryType-enum">HistoryType</a></b> { ShallowHistory, DeepHistory }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qhistorystate.html#QHistoryState">__init__</a></b> (<i>self</i>, QState&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qhistorystate.html#QHistoryState-2">__init__</a></b> (<i>self</i>, HistoryType&#160;<i>type</i>, QState&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QAbstractState <b><a href="qhistorystate.html#defaultState">defaultState</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhistorystate.html#event">event</a></b> (<i>self</i>, QEvent&#160;<i>e</i>)</li><li><div class="fn" />HistoryType <b><a href="qhistorystate.html#historyType">historyType</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qhistorystate.html#onEntry">onEntry</a></b> (<i>self</i>, QEvent&#160;<i>event</i>)</li><li><div class="fn" /><b><a href="qhistorystate.html#onExit">onExit</a></b> (<i>self</i>, QEvent&#160;<i>event</i>)</li><li><div class="fn" /><b><a href="qhistorystate.html#setDefaultState">setDefaultState</a></b> (<i>self</i>, QAbstractState&#160;<i>state</i>)</li><li><div class="fn" /><b><a href="qhistorystate.html#setHistoryType">setHistoryType</a></b> (<i>self</i>, HistoryType&#160;<i>type</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QHistoryState class provides a means of returning to a
previously active substate.</p>
<p>A history state is a pseudo-state that represents the child
state that the parent state was in the last time the parent state
was exited. A transition with a history state as its target is in
fact a transition to one of the other child states of the parent
state. QHistoryState is part of <a href="statemachine-api.html">The
State Machine Framework</a>.</p>
<p>Use the <a href="qhistorystate.html#defaultState-prop">setDefaultState</a>()
function to set the state that should be entered if the parent
state has never been entered. Example:</p>
<pre class="cpp">
 <span class="type"><a href="qstatemachine.html">QStateMachine</a></span> machine;

 <span class="type"><a href="qstate.html">QState</a></span> <span class="operator">*</span>s1 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qstate.html">QState</a></span>();
 <span class="type"><a href="qstate.html">QState</a></span> <span class="operator">*</span>s11 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qstate.html">QState</a></span>(s1);
 <span class="type"><a href="qstate.html">QState</a></span> <span class="operator">*</span>s12 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qstate.html">QState</a></span>(s1);

 <span class="type">QHistoryState</span> <span class="operator">*</span>s1h <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QHistoryState</span>(s1);
 s1h<span class="operator">-</span><span class="operator">&gt;</span><a href="qhistorystate.html#defaultState-prop">setDefaultState</a>(s11);

 machine<span class="operator">.</span>addState(s1);

 <span class="type"><a href="qstate.html">QState</a></span> <span class="operator">*</span>s2 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qstate.html">QState</a></span>();
 machine<span class="operator">.</span>addState(s2);

 <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>();
 <span class="comment">// Clicking the button will cause the state machine to enter the child state</span>
 <span class="comment">// that s1 was in the last time s1 was exited, or the history state's default</span>
 <span class="comment">// state if s1 has never been entered.</span>
 s1<span class="operator">-</span><span class="operator">&gt;</span>addTransition(button<span class="operator">,</span> SIGNAL(clicked())<span class="operator">,</span> s1h);
</pre>
<p>By default a history state is shallow, meaning that it won't
remember nested states. This can be configured through the <a href="qhistorystate.html#historyType-prop">historyType</a> property.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="HistoryType-enum" />QHistoryState.HistoryType</h3><p>This enum specifies the type of history that a <a href="qhistorystate.html">QHistoryState</a> records.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QHistoryState.ShallowHistory</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">Only the immediate child states of the parent
state are recorded. In this case a transition with the history
state as its target will end up in the immediate child state that
the parent was in the last time it was exited. This is the
default.</td>
</tr>
<tr>
<td class="topAlign"><tt>QHistoryState.DeepHistory</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">Nested states are recorded. In this case a
transition with the history state as its target will end up in the
most deeply nested descendant state the parent was in the last time
it was exited.</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QHistoryState" />QHistoryState.__init__ (<i>self</i>, <a href="qstate.html">QState</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a new shallow history state with the given
<i>parent</i> state.</p>


<h3 class="fn"><a name="QHistoryState-2" />QHistoryState.__init__ (<i>self</i>, <a href="qhistorystate.html#HistoryType-enum">HistoryType</a>&#160;<i>type</i>, <a href="qstate.html">QState</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a new history state of the given <i>type</i>, with
the given <i>parent</i> state.</p>


<h3 class="fn"><a name="defaultState" /><a href="qabstractstate.html">QAbstractState</a> QHistoryState.defaultState (<i>self</i>)</h3><h3 class="fn"><a name="event" />bool QHistoryState.event (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>e</i>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p>


<h3 class="fn"><a name="historyType" /><a href="qhistorystate.html#HistoryType-enum">HistoryType</a> QHistoryState.historyType (<i>self</i>)</h3><h3 class="fn"><a name="onEntry" />QHistoryState.onEntry (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>event</i>)</h3><p>Reimplemented from <a href="qabstractstate.html#onEntry">QAbstractState.onEntry</a>().</p>


<h3 class="fn"><a name="onExit" />QHistoryState.onExit (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>event</i>)</h3><p>Reimplemented from <a href="qabstractstate.html#onExit">QAbstractState.onExit</a>().</p>
<h3 class="fn"><a name="setDefaultState" />QHistoryState.setDefaultState (<i>self</i>, <a href="qabstractstate.html">QAbstractState</a>&#160;<i>state</i>)</h3><h3 class="fn"><a name="setHistoryType" />QHistoryState.setHistoryType (<i>self</i>, <a href="qhistorystate.html#HistoryType-enum">HistoryType</a>&#160;<i>type</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>